<% stylesheet 'foreman_remote_execution/foreman_remote_execution' %>
<% title _('Job invocations') %>

<% title_actions(job_invocations_buttons) %>

<table class="<%= table_css_classes('table-condensed table-fixed') %>">
  <thead>
    <tr>
      <th><%= sort :description, :as => _('Description') %></th>
      <th class="col-md-1"><%= _('Search Query') %></th>
      <th class="col-md-1"><%= _('Status') %></th>
      <th class="col-md-1"><%= _('Succeeded') %></th>
      <th class="col-md-1"><%= _('Failed') %></th>
      <th class="col-md-1"><%= _('Pending') %></th>
      <th class="col-md-1"><%= _('Total hosts') %></th>
      <th class="col-md-2"><%= sort :start_at, :as => _('Start') %></th>
    </tr>
  </thead>

  <tbody>
    <% @job_invocations.each do |invocation| %>
      <tr>
        <td class="text_warp"><%= link_to_if_authorized invocation_description(invocation), hash_for_job_invocation_path(invocation).merge(:auth_object => invocation, :permission => :view_job_invocations, :authorizer => authorizer) %></td>
        <td><%= trunc_with_tooltip(invocation&.targeting&.search_query, 15) %></td>
        <td><%= link_to_invocation_task_if_authorized(invocation) %></td>
        <td><%= invocation_result(invocation, :success_count) %></td>
        <td><%= invocation_result(invocation, :failed_count) %></td>
        <td><%= invocation_result(invocation, :pending_count) %></td>
        <td><%= invocation_result(invocation, :total_count) %></td>
        <td><%= time_in_words_span(invocation.start_at) %></td>
      </tr>
    <% end %>
  </tbody>
</table>
<%= will_paginate_with_info @job_invocations %>
